fix #810: remove restriction on $ref format#879
fix #810: remove restriction on $ref format#879ctreatma wants to merge 2 commits intoOpenAPITools:masterfrom
Conversation
5025731 to
996db4e
Compare
996db4e to
c4e1108
Compare
| final String baseRef = getBaseRefForType(refType.getName()); | ||
| if (!ref.startsWith(baseRef)) { | ||
| throw new IllegalArgumentException("Invalid ref: " + ref); | ||
| // If the ref doesn't point to something in #/components, |
There was a problem hiding this comment.
So, looks like just removing this validation would not work well. getRefName method is used by resolveRef method. Under the hood it searches referenced objects only in components section and does not consider remote files. So we need to think here about full support of the remote refs, instead of just removing the validation.
There was a problem hiding this comment.
Interesting; I would have expected an issue like that to be caught by this assertion, since the baseline spec uses an external ref to define the common properties of the Cat schema and the updated spec defines those properties inline.
Is there a different test I could write that would exercise remote ref resolution? Once I have a failing test demonstrating the issue I can work on addressing it.
There was a problem hiding this comment.
I added a few more tests to cover different styles of external $ref and based on the test results, it looks like external references are all being resolved correctly for the purposes of generating a diff. (Although I haven't added a test for external URL references.) Most of the tests added here are checking for an empty diff, but I did add one test to confirm that changes in the content of a remote $ref are detected as a diff.
This updates the
RefPointerclass to return the full$refvalue for references that are not under#/components/instead of throwing anIllegalArgumentException. This change enablesopenapi-diffto run successfully against specs that use any valid$refformat rather than prescribing one specific approach to defining references.Fixes #810